package com.moon.admin.tools.config;


import com.moon.admin.framework.util.JsonUtils;
import com.moon.admin.tools.domain.Message;

import javax.websocket.Decoder;
import javax.websocket.EndpointConfig;

/**
 * Created by tomoya at 2019/5/27
 */
public class MessageDecoder implements Decoder.Text<Message> {

  @Override
  public Message decode(String s) {
    return JsonUtils.str2obj(s, Message.class);
  }

  @Override
  public boolean willDecode(String s) {
    return s.startsWith("{") && s.endsWith("}");
  }

  @Override
  public void init(EndpointConfig endpointConfig) {

  }

  @Override
  public void destroy() {
  }
}
